package badgegenerator.controller;

import badgegenerator.model.BadgeProject;
import badgegenerator.model.User;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ValueChangeEvent;

@ManagedBean(name="userMainPageController")
@SessionScoped
public class UserMainPageController {
    private User user;
    private Integer currentProjectID;
    private BadgeProject currentProject;
    private String [] checkedEmployees;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String [] getCheckedEmployees() {
        return checkedEmployees;
    }

    public void setCheckedEmployees(String [] checkedEmployees) {
        this.checkedEmployees = checkedEmployees;
    }

    public BadgeProject getCurrentProject() {
        changeCurrentProjectByCurrentProjectId();
        return currentProject;
    }

    public void setCurrentProject(BadgeProject currentProject) {
        this.currentProject = currentProject;
    }

    public Integer getCurrentProjectID() {
        return currentProjectID;
    }

    public void setCurrentProjectID(Integer currentProjectID) {
        this.currentProjectID = currentProjectID;
    }
    
    private void changeCurrentProjectByCurrentProjectId(){
        for(int i = 0; i < user.getProjectList().size(); i++){
            if(user.getProjectList().get(i).getId().equals(currentProjectID))
                currentProject = user.getProjectList().get(i);
        }
    }
}
